﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Box.Cliente.Control
{
    public partial class frmListRoles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
              string[] allRoles = Roles.GetAllRoles();

                IEnumerable<string> rolesDisp = allRoles;

                lbRoles.DataSource = rolesDisp;
                lbRoles.DataBind();
            
        }

        protected void btnCrearRol_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Roles.RoleExists(txtNewRol.Text))
                {
                    Roles.CreateRole(txtNewRol.Text);                
                }
                else
                {
                    lblMsgError.Text = "El Rol ya Existe";
                }
            }
            catch (Exception)
            {
                
               Response.Redirect("~/RedireccionErrores/500.aspx");
            }
           
        }
    }
}